<!-- 全局js -->
<script src="/static/js/libs/jquery.min.js"></script>
<script src="/static/js/libs/jquery-ui-1.10.4.min.js"></script>
<script src="/static/js/libs/bootstrap.min.js"></script>

<script src="/static/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/static/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/static/js/plugins/toastr/toastr.min.js"></script>

<script src="/static/js/libs/juicer-min.js"></script>
<script src="/static/js/libs/dialog-min.js"></script>

<script src="/static/js/libs/highlight-8.4.min.js"></script>
<script src="/static/js/libs/FileSaver.min.js"></script>
<script src="/static/js/libs/json-format-min.js"></script>

<!-- 自定义js -->
<script type="text/javascript">
    var APP = APP || {};


    function NavToggle() {
        $('.navbar-minimalize').trigger('click');
    }

    function SmoothlyMenu() {
        if (!$('body').hasClass('mini-navbar')) {
            $('#side-menu').hide();
            setTimeout(
                function () {
                    $('#side-menu').fadeIn(500);
                }, 100);
        } else if ($('body').hasClass('fixed-sidebar')) {
            $('#side-menu').hide();
            setTimeout(
                function () {
                    $('#side-menu').fadeIn(500);
                }, 300);
        } else {
            $('#side-menu').removeAttr('style');
        }
    }

    $(document).ready(function () {
        // MetsiMenu
        $('#side-menu').metisMenu();

        //固定菜单栏
        $(function () {
            $('.sidebar-collapse').slimScroll({
                height: '100%',
                railOpacity: 0.9,
                alwaysVisible: false
            });
        });


        // 菜单切换
        $('.navbar-minimalize').click(function () {
            if($("body").hasClass("mini-navbar")){
                $("body").removeClass("mini-navbar");
            }
            else{
                $("body").addClass("mini-navbar");
            }
            SmoothlyMenu();
        });


        // 侧边栏高度
        function fix_height() {
            var heightWithoutNavbar = $("body > #wrapper").height() - 61;
            $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
        }
        fix_height();

        $(window).bind("load resize click scroll", function () {
            if (!$("body").hasClass('body-small')) {
                fix_height();
            }
        });

        //侧边栏滚动
        $(window).scroll(function () {
            if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
                $('#right-sidebar').addClass('sidebar-top');
            } else {
                $('#right-sidebar').removeClass('sidebar-top');
            }
        });

        $('.full-height-scroll').slimScroll({
            height: '100%'
        });

        $('#side-menu>li').click(function () {
            if ($('body').hasClass('mini-navbar')) {
                NavToggle();
            }
        });
        $('#side-menu>li li a').click(function () {
            if ($(window).width() < 769) {
                NavToggle();
            }
        });

        $('.nav-close').click(function(){
             if($("body").hasClass("mini-navbar")){
                $("body").removeClass("mini-navbar");
            }
            else{
                $("body").addClass("mini-navbar");
            }
            SmoothlyMenu();
        });

        //ios浏览器兼容性处理
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            $('#content-main').css('overflow-y', 'auto');
        }

        //nav close 事件
        $("#nav-section").mouseenter(function(){
          $(".nav-close").css("display","block");
        });
        $("#nav-section").mouseover(function(){
          $(".nav-close").css("display","block");
        });
        $("#nav-section").mouseout(function(){
          $(".nav-close").css("display","none");
        });

    });

    $(window).bind("load resize", function () {
        if ($(this).width() < 769) {
            $('body').addClass('mini-navbar');
            $('.navbar-static-side').fadeIn();
        }
    });
</script>
<script src="/static/js/orange.js?v=0.6"></script>
<script type="text/javascript">
    APP.Common.init();
</script>
